package com.czh.springboot04.service.serviceimpl;

import com.czh.springboot04.entity.Coursecollection;
import com.czh.springboot04.mapper.CoursecollectionMapper;
import com.czh.springboot04.service.CoursecollectionService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class CoursecollectionServiceImpl implements CoursecollectionService {
    @Autowired
    CoursecollectionMapper coursecollectionMapper;
    @Override
    public PageInfo<Coursecollection> selectCoursemark(int pageNum, int pageSize, String nickName, String courseName) {
        PageHelper.startPage(pageNum,pageSize);
        List<Coursecollection> list = coursecollectionMapper.selectCoursemark(nickName, courseName);
        PageInfo<Coursecollection> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public Coursecollection selectCoursemarkByUserIdAndKcid(int userId, int kcid) {
        Coursecollection coursecollection = coursecollectionMapper.selectCoursemarkByUserIdAndKcid(userId, kcid);
        return coursecollection;
    }

    @Override
    public int insertCoursecollection(int userid, int kcid) {
        int i = coursecollectionMapper.insertCoursecollection(userid, kcid);
        return i;
    }

    @Override
    public int deleteCoursecollection(int userid, int kcid) {
        int i=coursecollectionMapper.deleteCoursecollection(userid, kcid);
        return i;
    }
}
